package com.wmh.baseservice.operationaid.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wmh.baseservice.operationaid.entity.ProductDetails;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;
import java.util.stream.Collectors;

/**
* @author 牛威龙
* @description 针对表【operation_aid_product_details】的数据库操作Mapper
* @createDate 2023-09-07 15:45:59
*/
public interface ProductDetailsMapper extends BaseMapper<ProductDetails> {
    default List<String> getStoreOptions(){
        return selectList(new LambdaQueryWrapper<ProductDetails>()
                .groupBy(ProductDetails::getStoreName)
                .orderByDesc(ProductDetails::getCreateTime)
                .select(ProductDetails::getStoreName)
        ).stream().map(ProductDetails::getStoreName).collect(Collectors.toList());
    }

    default List<String> getDataCycleOptions(){
        return selectList(new LambdaQueryWrapper<ProductDetails>()
                .groupBy(ProductDetails::getDataCycle)
                .orderByDesc(ProductDetails::getCreateTime)
                .select(ProductDetails::getDataCycle)
        ).stream().map(ProductDetails::getDataCycle).collect(Collectors.toList());
    }
}




